﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.IO.IsolatedStorage;
using CoreSharp.Wp7;
using System.Runtime.Serialization;

namespace CoreSharp.Keyboard
{
    [DataContract]
    public class KeyboardSetting
    {
        [DataMember]
        public bool HighSensitivityMode { get; set; }
    }


    public class GlobalKeyboardSetting
    {
        private static KeyboardSetting _Global;

        public static KeyboardSetting Global
        {
            get
            {
                if (_Global == null)
                {
                    try
                    {
                        //_Global = IsolatedStorageSettings.ApplicationSettings["KeyboardSettings"] as KeyboardSetting;
                        _Global = (typeof(KeyboardSetting)).Load<KeyboardSetting>("coresharp-keyboardsetting");

                        Application.Current.Exit += (s,e) =>
                        {
                            _Global.Save("coresharp-keyboardsetting");
                        };
                    }
                    catch (Exception)
                    {
                        _Global = new KeyboardSetting()
                        {
                            
                        };
                    }
                }
                return _Global;
            }
        }

        public KeyboardSetting GlobalSetting { get { return GlobalKeyboardSetting.Global; } }

    }
}
